#include<bits/stdc++.h>
using namespace std;
int n,m,L,V,p[100005],mm,nn;
struct car{
    int d,v,a;
    double s,e;
    bool cs,aa;
}c[100005];
bool cmp(car a,car b){
    if(a.s==b.s)return a.e<b.e;
    return a.s<b.s;
}
void solve(car c){
    if(c.a<=0&&c.v<=V){
        nn++;
        c.cs=1;
        return;
    }if(c.a<0){
        c.s=c.d;
        int t=(V-c.v)*1.0/c.a;
        c.e=c.v*t+0.5*c.a*pow(t,2);
    }if(c.a==0){
        c.aa=1;
        c.s=c.d;
        c.e=L;
    }if(c.a>0){
        int t=(c.v-V)*1.0/c.a;
        c.s=L-(c.v*t+0.5*c.a*pow(t,2));
        c.e=L;
        if(c.s>=L){
            nn++;
            c.cs=1;
            return;
        }
    }
    for(int i=0;i<m;i++){
        if(!c.cs&&(p[i]>c.s&&p[i]<c.e||p[i]>=c.s&&p[i]<=c.e&&c.aa))return;
    }
    nn++;
}
void solve2(){
    sort(c,c+n,cmp);
    int ss=c[0].e;
    for(int i=0;i<n;i++){
        if(c[i].cs==1)continue;
        if(ss<=c[i].s&&c[i].aa==0||ss<c[i].s){
            mm++;
            ss=c[i].e;
        }
    }
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    scanf("%d",&T);
    while(T--){
        scanf("%d%d%d%d",&n,&m,&L,&V);
        for(int i=0;i<n;i++)scanf("%d%d%d",&c[i].d,&c[i].v,&c[i].a);
        for(int i=0;i<m;i++)scanf("%d",&p[i]);
        for(int i=0;i<n;i++){
            solve(c[i]);
        }
        solve2();
        printf("%d %d",n-nn,m-mm);
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}